package com.geekstudy.week12;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

public class RedisSentinelDemo {
    
    public static void main(String[] args) {

        Set<String> sentinelSet = new HashSet<String>();
        sentinelSet.add("127.0.0.1:20001");

        JedisSentinelPool jedisSentinelPool = new JedisSentinelPool("mymaster", sentinelSet);
        Jedis jedis = jedisSentinelPool.getResource();
        Set<String> keySet = jedis.keys("*");
        System.out.println(" keySet:" + keySet);

        String key = "java_sentinel_key";
        String setResult = jedis.set(key, "demo 202109");
        System.out.println(" setResult:" + setResult);

        String  getValue = jedis.get(key);
        System.out.println(" getValue:" + getValue);




    }
}
